1. /* scfcosbs.cpp by K.Tsuru */
  2. // function ID = 9121 since ver.2.18
  3. /*****************************************
  4. SComplex class
  5. It returns cos(z) using binary splitting method.
  6. Let z = x+iy,
  7. cos(z) = cos(x)*cosh(y)-i*sin(x)sinh(y).
  8. *****************************************/
  9. #ifndef SN_H
  10. #include "sn.h"
  11. #endif
  12. SComplex CcosBS(const SComplex& z){
  13. SDouble c, s, ch, sh;
  14. CosSinBS(z.Real(), c, s); // c = cos(x), s = sin(x)
  15. SDouble e, r;
  16. int is = z.Imag().Sign(9121);
  17. if(is > 0) {
  18. e = ExpBS(z.Imag()); // = exp(y)
  19. r = 1/e;
  20. ch = DDiv2(e + r); // = cosh(y)
  21. sh = ch - e; // = -sinh(y)
  22. } else if(is == 0) {
  23. ch = 1.0; sh = 0.0;
  24. } else {
  25. e = ExpBS(-z.Imag()); // = exp(-y)
  26. r = ONE/e;
  27. ch = DDiv2(e + r); // = cosh(-y)
  28. sh = ch - r; // = -sinh(-y)
  29. }
  30. return SComplex(c * ch, s * sh);
  31. }

scfcosbs.cpp : last modifiled at 2017/08/22 20:49:19(836 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:09 (Fri Oct 06 15:27:09 2017).